<!-- 注意这里不需要写`<html><body>`这些东西，它是一个html片段，不是完整的html页面 -->
<form id="addOrUpdateForm" lay-filter="addOrUpdateForm" class="layui-form model-form">
    <div class="layui-col-md12">
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">客户</label>
            <div class="layui-input-block">
                <div id="sexCustomer"></div>
            </div>
        </div>

        <div class="layui-form-item">
            <button type="button" class="layui-btn layui-btn-normal" id="excelFile" style="margin-left: 80px">选择文件
            </button>
        </div>

        <div class="layui-form-item">
            <button type="button" class="layui-btn layui-btn-normal" id="submitFile" style="margin-left: 80px">开始上传
            </button>
            <button class="layui-btn layui-btn-primary" type="button" style="margin-right: 80px;float: right" ew-event="closeDialog">取消</button>
        </div>
    </div>



</form>

<script>
    layui.use(['upload', 'layer', 'form', 'admin', 'table', 'tableX', 'xnUtil', 'xmSelect', 'laydate'], function () {
        let $ = layui.jquery;
        let upload = layui.upload;
        let layer = layui.layer;
        let form = layui.form;
        let table = layui.table;
        let tableX = layui.tableX;
        let admin = layui.admin;
        let xnUtil = layui.xnUtil;
        let xmSelect = layui.xmSelect;
        let laydate = layui.laydate;

        // 渲染客户字典下拉
        let customerDataRenderIns = xmSelect.render({
            el: '#sexCustomer',
            name: 'customerName',
            data: xnUtil.getDictDataByDictTypeCode('customer_info', null),
            layVerify: 'required',
            layVerType: 'tips',
            radio: true,
            clickClose: true,
            model: {icon: 'hidden', label: {type: 'text'}},
            prop: {
                name: 'name',
                value: 'code'
            },
            tips: '请选择客户'
        });

        //选完文件后不自动上传
        upload.render({
            elem: '#excelFile'
            , url: '/sysMould/uploadExcel' //此处配置你自己的上传接口即可
            , auto: false
            , accept: 'file'
            , exts: 'xls|xlsx'
            //,multiple: true
            , bindAction: '#submitFile'
            , before: function () {
                let customer = $("#sexCustomer .label-content").html();
                customer = customer.trim();
                if (customer === "") {
                    layer.msg('请选择客户', {icon: 5, time: 3000});
                    return false;
                } else {
                    layer.msg('上传中,请稍后！', {icon: 5, time: 30000});
                    // layer.load();
                    this.data = {"customer": customer};
                }
            }
            , done: function (res) {
                layer.closeAll('loading');
                admin.putLayerData('formOk', true, '#addOrUpdateForm');
                admin.closeDialog('#addOrUpdateForm');
            }
        });

    });
</script>